package com.talkweb.platform.commonapi.query;

import java.io.Serializable;

import io.swagger.annotations.ApiModelProperty;

/**
 * 排序方法类
 * 
 * @author lzy
 */
public class OrderMethod implements Serializable
{
    /**
    *注释内容
    */
    private static final long serialVersionUID = -8650625910124047676L;

    /**
     * 排序字段名称
     * <p>
     * 取值范围在各请求类中进行定义
     */
    @ApiModelProperty(value = "排序字段名称")
    private String field;
    
    /**
     * 排序方式
     * <p>
     * 取值范围为：
     * <p>
     * <li>{@link Method#ASC}
     * <li>{@link Method#DESC}
     */
    @ApiModelProperty(value = "排序方式")
    private Method method = Method.ASC;
    
    /**
     * 排序方法枚举类
     * 
     * @author zhangjian
     * @version [版本号, 2011-9-24]
     */
    public enum Method
    {
        
        /**
         * 升序
         */
        ASC("ASC"),

        /**
         * 降序
         */
        DESC("DESC"),

        /**
         * 升序，null是后面
         * 
         */
        DESC_NULLS_LAST("DESC NULLS LAST");
        
        private final String value;
        
        private Method(String value)
        {
            this.value = value;
        }
        
        public String getValue()
        {
            return value;
        }
        
        @Override
        public String toString()
        {
            return value;
        }
    }
    
    /**
     * 默认构造函数
     */
    public OrderMethod()
    {
    }
    
    /**
     * 构造函数
     */
    public OrderMethod(String field, Method method)
    {
        this.field = field;
        this.method = method;
    }
    
    public String getField()
    {
        return field;
    }
    
    public void setField(String field)
    {
        this.field = field;
    }
    
    public Method getMethod()
    {
        return method;
    }
    
    public void setMethod(Method method)
    {
        this.method = method;
    }
    
    @Override
    public String toString()
    {
        return "OrderMethod [field=" + field + ", method=" + method + "]";
    }
    
}
